package security.crypto;

public class CipherFactory {
	
	private Cipher cipher;
	private static CipherFactory instance;
	
	private CipherFactory(Cipher cipher){
		this.cipher = cipher;
	}
	
	public static void register(Cipher cipher){
		if(instance != null)
			throw new RuntimeException("A manager has already been registred.");
		
		instance = new CipherFactory(cipher);
	}
	
	public static CipherFactory getInstance(){
		if(instance == null)
			throw new RuntimeException("No manager has been registred yet.");
		return instance;
	}
	
	public static Cipher getCipher(){
		return getInstance().cipher;
	}
}
